
*****AI Security Index******

****DO-FIle for Creating ASI******

*******Generating Logged Measures**********

gen GDP_log = log(gdpcurrentusnygdpmktpcd)
gen militaryexpenditure_log = log(militaryexpenditurecurrentusdmsm)
gen private_public_log = log(investmentinenergywithprivatepar)
gen privae_puglic_log_2 = log(publicprivatepartnershipsinvestm)
gen energy_production_log = log(quadrillionbtu)
gen datacenters_log = log(datacenters)


*******Generated Weighted Measures********

gen income10 = income * 0.10

gen EP_W = quadrillionbtu * 0.25

gen EE_W = EE_Score * 0.10

gen AI_W = totalscore * 0.50

gen NCPI_W = NCPI * 0.50


****example********Don not use; This is example******

egen ASI_1 = rowtotal(var1 var2 var3 var4)
replace ASI_1 = . if missing(var1) | missing(var2) | missing(var3) | missing(var4)

*****example******

******* ASI_1 = GDP(logged) + Energy Production (.25) + Energy Efficiency (.10) + AI Readiness (.50) + Military Expenditures (logged) + ME(GDP) +NCPI (.50) ******

******************Generating ASI******************

egen ASI_1 = rowtotal(GDP_log datacenters_log EP_W EE_W AI_W militaryexpenditure_log militaryexpenditureofgdpmsmilxpn NCPI_W)
replace ASI_1 =. if missing(GDP_log)| missing(datacenters_log)| missing(EP_W)| missing(EE_W)| missing(AI_W)| missing(militaryexpenditure_log)| missing(militaryexpenditureofgdpmsmilxpn)| missing(NCPI_W)  

egen ASI_2 = rowtotal(GDP_log EP_W EE_W AI_W militaryexpenditure_log militaryexpenditureofgdpmsmilxpn NCPI_W)
replace ASI_2 =. if missing(GDP_log)| missing(EP_W)| missing(EE_W)| missing(AI_W)| missing(militaryexpenditure_log)| missing(militaryexpenditureofgdpmsmilxpn)| missing(NCPI_W)  

egen ASI_3 = rowtotal(GDP_log EP_W EE_W AI_W militaryexpenditure_log militaryexpenditureofgdpmsmilxpn)
replace ASI_3 =. if missing(GDP_log)| missing(EP_W)| missing(EE_W)| missing(AI_W)| missing(militaryexpenditure_log)| missing(militaryexpenditureofgdpmsmilxpn)

egen ASI_4 = rowtotal(GDP_log EP_W AI_W militaryexpenditure_log militaryexpenditureofgdpmsmilxpn)
replace ASI_4 =. if missing(GDP_log)| missing(EP_W)| missing(AI_W)| missing(militaryexpenditure_log)| missing(militaryexpenditureofgdpmsmilxpn)

*********************************

****Generating Measures to deterimine the % composision in ASI**********

generate pct_measure1 = (GDP_log/ASI_1) * 100
generate pct_measure2 = (datacenters_log/ASI_1) * 100
generate pct_measure3 = (EP_W/ASI_1) * 100
generate pct_measure4 = (EE_W/ASI_1) * 100
generate pct_measure5 = (AI_W/ASI_1) * 100
generate pct_measure6 = (militaryexpenditure_log/ASI_1) * 100
generate pct_measure7 = (militaryexpenditureofgdpmsmilxpn/ASI_1) * 100
generate pct_measure8 = (NCPI_W/ASI_1) * 100

****************************

****renaming vars********

Sumvar 3 = ASI 4
Sumvar 4 = ASI 1
Sumvar 2 = ASI 3
Sumvar 1 = ASI 2

rename sumvar_4 ASI_1
rename sumvar_1 ASI_2
rename sumvar_2 ASI_3
rename sumvar_3 ASI_4


*******************************
